From 555bfdeb80429b3baf52768a71ad73e8bd2cef1d Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 20 Jul 2026 20:54:46 +0000 Subject: [PATCH] Create, document, index, and trigger COMMUNITY_MEMBERSHIP_UPDATE_LOG --- db/schemas/housekeeping/indexes/Makefile | 1 + .../create/community_membership_update_log.m4 | 36 ++++++ .../drop/community_membership_update_log.m4 | 27 +++++ db/schemas/housekeeping/tables/Makefile | 1 + .../create/community_membership_update_log.m4 | 38 ++++++ db/schemas/lib/triggers/Makefile | 3 +- .../create/community_membership_update_log.m4 | 49 ++++++++ .../drop/community_membership_update_log.m4 | 23 ++++ doc/src/epilog.inc.m4 | 22 ++++ doc/src/housekeeping.m4 | 1 + .../community_membership_update_log.m4 | 113 ++++++++++++++++++ 11 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 db/schemas/housekeeping/indexes/create/community_membership_update_log.m4 create mode 100644 db/schemas/housekeeping/indexes/drop/community_membership_update_log.m4 create mode 100644 db/schemas/housekeeping/tables/create/community_membership_update_log.m4 create mode 100644 db/schemas/lib/triggers/create/community_membership_update_log.m4 create mode 100644 db/schemas/lib/triggers/drop/community_membership_update_log.m4 create mode 100644 doc/src/housekeeping/community_membership_update_log.m4 diff --git a/db/schemas/housekeeping/indexes/Makefile b/db/schemas/housekeeping/indexes/Makefile index 39ee291..7fbbb8f 100644 --- a/db/schemas/housekeeping/indexes/Makefile +++ b/db/schemas/housekeeping/indexes/Makefile @@ -22,6 +22,7 @@ ORDER := aggression_event_log \ biography_log \ chimps_on_tikis \ + community_membership_update_log \ tlk_brecord_notes_codes ## diff --git a/db/schemas/housekeeping/indexes/create/community_membership_update_log.m4 b/db/schemas/housekeeping/indexes/create/community_membership_update_log.m4 new file mode 100644 index 0000000..1c7b6db --- /dev/null +++ b/db/schemas/housekeeping/indexes/create/community_membership_update_log.m4 @@ -0,0 +1,36 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +CREATE UNIQUE INDEX IF NOT EXISTS + "DateOfUpdate + AnimID must be unique" + ON community_membership_update_log + (dateofupdate, animid); + +CREATE INDEX IF NOT EXISTS community_membership_update_log_animid + ON community_membership_update_log + (animid); +CREATE INDEX IF NOT EXISTS community_membership_update_log_madeby + ON community_membership_update_log + (madeby); + + diff --git a/db/schemas/housekeeping/indexes/drop/community_membership_update_log.m4 b/db/schemas/housekeeping/indexes/drop/community_membership_update_log.m4 new file mode 100644 index 0000000..0f22008 --- /dev/null +++ b/db/schemas/housekeeping/indexes/drop/community_membership_update_log.m4 @@ -0,0 +1,27 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +DROP INDEX IF EXISTS "DateOfUpdate + AnimID must be unique"; + +DROP INDEX IF EXISTS community_membership_update_log_animid; +DROP INDEX IF EXISTS community_membership_update_log_madeby; diff --git a/db/schemas/housekeeping/tables/Makefile b/db/schemas/housekeeping/tables/Makefile index 43e1b43..f15e8eb 100644 --- a/db/schemas/housekeeping/tables/Makefile +++ b/db/schemas/housekeeping/tables/Makefile @@ -23,6 +23,7 @@ ORDER := aggression_event_log \ biography_log \ chimps_on_tikis \ + community_membership_update_log \ tlk_brecord_notes_codes ## diff --git a/db/schemas/housekeeping/tables/create/community_membership_update_log.m4 b/db/schemas/housekeeping/tables/create/community_membership_update_log.m4 new file mode 100644 index 0000000..196ce67 --- /dev/null +++ b/db/schemas/housekeeping/tables/create/community_membership_update_log.m4 @@ -0,0 +1,38 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`tablemacros.m4')dnl +include(`grants.m4')dnl +dnl + +CREATE TABLE community_membership_update_log ( + key_column(`COMMUNITY_MEMBERSHIP_UPDATE_LOG', `ID', INTEGER) + ,dateofupdate DATE NOT NULL + ,animid_column() + ,description TEXT NOT NULL + notonlyspaces_check(`Description') + ,rationale TEXT NOT NULL + notonlyspaces_check(`Rationale') + ,madeby TEXT NOT NULL + REFERENCES people +); + +grant_priv(`COMMUNITY_MEMBERSHIP_UPDATE_LOG') diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 330b382..dffe2ff 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -58,7 +58,8 @@ ORDER := comm_ids \ elo_ranks_daily_mt_m \ aggression_event_log \ chimps_on_tikis \ - tlk_brecord_notes_codes + tlk_brecord_notes_codes \ + community_membership_update_log DROP_EXISTING := true diff --git a/db/schemas/lib/triggers/create/community_membership_update_log.m4 b/db/schemas/lib/triggers/create/community_membership_update_log.m4 new file mode 100644 index 0000000..e232efb --- /dev/null +++ b/db/schemas/lib/triggers/create/community_membership_update_log.m4 @@ -0,0 +1,49 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Triggers for the community_membership_update_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'community_membership_update_log_update_func'; +CREATE OR REPLACE FUNCTION community_membership_update_log_update_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for community_membership_update_log update trigger + -- + -- AGPL_notice(` --', `2026', + `The Meme Factory, Inc., www.karlpinc.com') + + cannot_change(`COMMUNITY_MEMBERSHIP_UPDATE_LOG', `ID') + + RETURN NULL; + END; +$$; + + +RAISE INFO 'community_membership_update_log_update_trigger'; +CREATE TRIGGER community_membership_update_log_update_trigger + AFTER INSERT OR UPDATE + ON community_membership_update_log FOR EACH ROW + EXECUTE PROCEDURE community_membership_update_log_update_func(); diff --git a/db/schemas/lib/triggers/drop/community_membership_update_log.m4 b/db/schemas/lib/triggers/drop/community_membership_update_log.m4 new file mode 100644 index 0000000..cad0a0b --- /dev/null +++ b/db/schemas/lib/triggers/drop/community_membership_update_log.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Drop triggers for community_membership_update_log table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS community_membership_update_log_update_func() CASCADE; diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 99f24fb..1e1c275 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -383,6 +383,28 @@ sdb_generated_rst()dnl .. |COMM_MEMBS_SOURCES.Description| replace:: :ref:`Description ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG| + replace:: + :ref:`COMMUNITY_MEMBERSHIP_UPDATE_LOG ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.ID| + replace:: + :ref:`ID ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.DateOfUpdate| + replace:: + :ref:`DateOfUpdate ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.AnimID| + replace:: + :ref:`AnimID ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.Description| + replace:: + :ref:`Description ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.Rationale| + replace:: + :ref:`Rationale ` +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.MadeBy| + replace:: + :ref:`MadeBy ` + .. |CYCLE_STATES| replace:: :ref:`CYCLE_STATES ` .. |CYCLE_STATES.Code| replace:: :ref:`Code ` diff --git a/doc/src/housekeeping.m4 b/doc/src/housekeeping.m4 index bdbbde8..2211453 100644 --- a/doc/src/housekeeping.m4 +++ b/doc/src/housekeeping.m4 @@ -36,4 +36,5 @@ The tables in this section are all in the ``housekeeping`` schema. housekeeping/aggression_event_log.rst housekeeping/biography_log.rst housekeeping/chimps_on_tikis.rst + housekeeping/community_membership_update_log.rst housekeeping/tlk_brecord_notes_codes.rst diff --git a/doc/src/housekeeping/community_membership_update_log.m4 b/doc/src/housekeeping/community_membership_update_log.m4 new file mode 100644 index 0000000..8347af4 --- /dev/null +++ b/doc/src/housekeeping/community_membership_update_log.m4 @@ -0,0 +1,113 @@ +.. Copyright (C) 2026 The Meme Factory, Inc. www.karlpinc.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +.. M4 setup +include(constants.m4)dnl +include(macros.m4)dnl +sdb_rst_quotes(`on')dnl +sdb_generated_rst()dnl + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG: + +COMMUNITY_MEMBERSHIP_UPDATE_LOG +------------------------------- + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG_summary| replace:: + Each row contains information on when and why the community + membership of an individual was updated. + There is, at most, one row per-individual, per-date of update. + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG_summary| + +The combination of |COMMUNITY_MEMBERSHIP_UPDATE_LOG.AnimID| and +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.DateOfUpdate| must be unique. + + +.. contents:: + :depth: 2 + + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG.ID: + +ID (IDentifier) +``````````````` + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.ID_summary| replace:: |idcol| + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.ID_summary| |notnull| + + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG.DateOfUpdate: + +DateOfUpdate +```````````` + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.DateOfUpdate_summary| replace:: + The date of the change in community. + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.DateOfUpdate_summary| + +|notnull| + + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG.AnimID: + +AnimID +`````` + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.AnimID_summary| replace:: + The |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| of the individual + who's community was updated. + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.AnimID_summary| + +|notnull| + + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG.Description: + +Description +``````````` + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.Description_summary| replace:: + A description of what was changed. + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.Description_summary| +|notonlyspaces| |notnull| + + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG.Rationale: + +Rationale +``````````` + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.Rationale_summary| replace:: + The rationale for the change. + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.Rationale_summary| +|notonlyspaces| |notnull| + + +.. _COMMUNITY_MEMBERSHIP_UPDATE_LOG.MadeBy: + +MadeBy +`````` + +.. |COMMUNITY_MEMBERSHIP_UPDATE_LOG.MadeBy_summary| replace:: + The person who made the change. + A |PEOPLE|.\ |PEOPLE.Person| value. + +|COMMUNITY_MEMBERSHIP_UPDATE_LOG.MadeBy_summary| +|notonlyspaces| |notnull| -- 2.34.1